﻿using System;

namespace CodeAffinity.FormAbstraction
{
    public class InvalidVisit : Exception
    {
        public InvalidVisit(IVisitedElement visited, IVisitor visitor) :
            base(
                 String.Format(
                    "{0} can't visit {1} by design",
                    visitor,
                    visited
                 )
             ) { }
    }

    public class ListControlNotValid : Exception
    {
        public ListControlNotValid(string dataPointName) :
            base(
                String.Format("You can't use a list control for {0}. Needs [ForeignKeyProperty] attribute. See {0} to add if necessary.}", dataPointName)
            ) { }
    }

    public class NoPrimaryKeySet : Exception
    {
        public NoPrimaryKeySet(Exception ex) :
            base("The current dataobject doesnt have [PrimaryKeyProperty] on its primary key field", ex) { }
    }

    public class DataReloadAttempted : Exception
    {
        public DataReloadAttempted(string objectName, string controlName) :
            base(
                String.Format("{0} tried to reload {1} after it was already loaded. Please make the control ID property look like this: \"DataClassBaseTypeName_PropertyName\"",
                objectName,
                controlName)
            ) { }
    }
}